package com.hualan.dao.impl;

import com.hualan.bean.PanghuShop;
import com.hualan.bean.PanghuShopGoods;
import com.hualan.dao.SelectShop;
import com.hualan.dao.ShopGoodsList;
import com.hualan.utils.C3P0Util;


import java.util.List;

public class SelectShopImpl implements SelectShop {
    private static ShopGoodsList shopGoodsList = new ShopGoodsListImpl();

    @Override
    public List<PanghuShopGoods> selectShop(String name, int page, int size) {
        List<PanghuShopGoods> list = null;
        if (!name.equals("")) {
            list = C3P0Util.query("select * from panghu_shop_goods where goods_name like ?", PanghuShopGoods.class, '%' + name + '%');
            for (PanghuShopGoods p : list) {
                PanghuShop panghuShop = shopGoodsList.selectById(p.getShopId());
                p.setGoodsShopName(panghuShop.getShopName());
            }
            return list;
        } else {
            return shopGoodsList.selectShopGoodsAll(page, size);
        }
    }
}
